package itheima.reggie.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import itheima.reggie.entity.User;
import itheima.reggie.mapper.UserMapper;
import itheima.reggie.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service("userService")
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService{
    @Autowired
    UserMapper userMapper;
    @Transactional
    public void userAdd(){
        User user = new User();
        user.setName("保存成功");
        user.setPhone("1");
        user.setStatus(1);
        userMapper.insert(user);
        user.setName("hhh");
        userMapper.updateById(user);
    }

    @Transactional
    @Override
    public boolean saveByEntity(User user) {
        this.save(user);
        return this.save(user);
    }
}
